package com.shrcl.engineerprocess.domain.impl;

import com.google.common.base.Objects;
import com.shrcl.engineerprocess.domain.TaskExtensionDelete;
import com.shrcl.engineerprocess.domain.TaskNotification;
import edu.fudan.langlab.domain.task.TSKTask;
import edu.fudan.langlab.domain.task.TSKTaskExtension;
import edu.fudan.mylang.pf.BaseService;
import edu.fudan.mylang.pf.IGenericQuery;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.TaskExtensionDelete")
public class TaskExtensionDeleteImpl extends BaseService implements TaskExtensionDelete {
  public void deleteTaskExt(final TSKTaskExtension tskext) {
    TSKTask _task = tskext.getTask();
    this.deleteTaskNotification(_task);
    TSKTask _task_1 = tskext.getTask();getObjectFactory().delete(_task_1);
    getObjectFactory().delete(tskext);
    
  }
  
  public void deleteTaskNotification(final TSKTask tsk) {
    IGenericQuery<TaskNotification> query=getObjectFactory().createGenericQuery(TaskNotification.class,"select e from com.shrcl.engineerprocess.domain.impl.TaskNotificationImpl as e   where ((e.tskTask) = (:tsk)) and  e.active = 1      ").setParameter("tsk",tsk);
    final TaskNotification taskN = query.uniqueResult();
    boolean _notEquals = (!Objects.equal(taskN, null));
    if (_notEquals) {getObjectFactory().delete(taskN);
      
    }
  }
}
